import { createRouter, createWebHashHistory } from 'vue-router'

// 扩展 RouteMeta 接口
declare module 'vue-router' {
  interface RouteMeta {
    title?: string
    hide?: boolean
  }
}

/**
 * 创建一个可以被 Vue 应用程序使用的路由实例
 * @method createRouter(options: RouterOptions): Router
 * @link 参考：https://next.router.vuejs.org/zh/api/#createrouter
 */
export const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: '/',
      component: () => import('@/layout/LayoutIndex.vue'),
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/home/HomeIndex.vue'),
          meta: {
            title: '首页'
          }
        },
        {
          path: '/sftp',
          name: 'sftp',
          component: () => import('@/views/sftp/SftpIndex.vue'),
          meta: {
            title: '服务器'
          }
        },
        {
          path: '/web',
          name: 'web',
          component: () => import('@/views/web/WebIndex.vue'),
          meta: {
            title: 'Web'
          }
        },
        {
          path: '/server',
          name: 'server',
          component: () => import('@/views/server/ServerIndex.vue'),
          meta: {
            title: 'Server'
          }
        },
        {
          path: '/running',
          name: 'running',
          component: () => import('@/views/running/RunningIndex.vue'),
          meta: {
            title: '本地运行'
          }
        },
        {
          path: '/file',
          name: 'file',
          component: () => import('@/views/file/FileIndex.vue'),
          meta: {
            title: '文件管理',
            hide: true
          }
        },
        {
          path: '/upload',
          name: 'upload',
          component: () => import('@/views/upload/UploadIndex.vue'),
          meta: {
            title: '更新器',
            hide: true
          }
        },
        {
          path: '/terminal',
          name: 'terminal',
          component: () => import('@/views/terminal/TerminalIndex.vue'),
          meta: {
            title: '终端',
            hide: true
          }
        },
        {
          path: '/terminal_theme',
          name: 'terminal_theme',
          component: () => import('@/views/terminal/TerminalTheme.vue'),
          meta: {
            title: '终端主题',
            hide: true
          }
        },
        {
          path: '/config',
          name: 'config',
          component: () => import('@/views/config/ConfigIndex.vue'),
          meta: {
            title: '系统配置',
            hide: true
          }
        }
      ]
    }
  ]
})

export default router
